package org.hh.jga.adaptor;

import org.hh.jga.util.Pair;

import net.sf.jga.fn.UnaryFunctor;

/**
 * Project Pair's second element
 * 
 * @author Hong Hong
 *
 * @param First pair item type
 * @param Second pair item type
 */

public class ProjectPair2nd<T1, T2> extends UnaryFunctor<Pair<T1, T2>, T2> {
	private static final long serialVersionUID = -4606721706619026608L;

	@Override
	public T2 fn(Pair<T1, T2> arg) {
		return arg.second;
	}
    /**
     * Calls the Visitor's <code>visit(Project1st)</code> method, if it
     * implements the nested Visitor interface.
     */
    public void accept(net.sf.jga.fn.Visitor v) {
        if (v instanceof ProjectPair2nd.Visitor)
            ((ProjectPair2nd.Visitor)v).visit(this);
        else
            v.visit(this);
    }
    
    // Object overrides

    public String toString() {
        return "ProjectPair2nd";
    }
    
     // AcyclicVisitor
     
    /**
     * Interface for classes that may interpret an <b>Project1st</b> functor.
     */
    public interface Visitor extends net.sf.jga.fn.Visitor {
        public void visit(ProjectPair2nd<?,?> host);
    }

}
